﻿using Newtonsoft.Json.Serialization;
using System.Linq;
using System.Net.Http.Formatting;
using System.Web.Http;

namespace Weapp.Web
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            //removing default xml
            var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
            config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);

            var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            config.Routes.MapHttpRoute(
                name: "SizeCategory",
                routeTemplate: "api/SizeCategory/{id}",
                defaults: new {controller = "SizeCategory", id = RouteParameter.Optional});
            config.Routes.MapHttpRoute(
                name:"UserDnD",
                routeTemplate:"api/UserDnD/{id}",
                defaults: new {controller = "UserDnD", id = RouteParameter.Optional });
        }
    }
}
